<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddColumnReviewRequestNodeInfoInNoteEntityRelationTable extends AbstractMigration
{
    public function up()
    {
        $this->table('note_entity_relation')
            ->addColumn('review_request_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '审批申请id'])
            ->addColumn('review_request_node_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '审批申请节点id'])
            ->addIndex(['review_request_node_id'], ['name' => 'idx_review_request_node', 'type' => 'normal'])
            ->addIndex(['review_request_id'], ['name' => 'idx_review_request', 'type' => 'normal'])
            ->save();
    }

    public function down()
    {
        $this->table('note_entity_relation')
            ->removeIndexByName('review_request_node_id')
            ->removeIndexByName('review_request_id')
            ->removeColumn('review_request_id')
            ->removeColumn('review_request_node_id')
            ->save();
    }
}
